/*
 * Sphere.h
 *
 *  Created on: May 13, 2012
 *      Author: walther
 */

#ifndef SPHERE_H_
#define SPHERE_H_

#include "Object.h"
#include "Material.h"

class Sphere : public Object
{
public:
    /**
     * Constructor
     * @param centerX X coordinate of the Sphere center
     * @param centerY Y coordinate of the Sphere center
     * @param centerZ Z coordinate of the Sphere center
     * @param radius Radius of the sphere
     */
    Sphere( double centerX, double centerY, double centerZ, double radius );

    /**
     * Destructor
     */
    virtual ~Sphere();
    
   /**
     * From Object interface:
     * Computes the intersection of the object with the given ray
     * @param ray Ray that may intersect the object
     * @param t Parameter of the ray, indicating how far from the ray origin is 
     *          the intersection
     * @return true if intersects, false otherwise
     */
    bool computeRayIntersection( Ray& ray, double& t );
    
    /**
     * From Object interface:
     * Gives the Normal vector of the object at a given point.
     * If the point is not in the object's surface, returns null vector (0,0,0,1)
     * @param point Point in the object's surface
     * @return the Normal vector of the object
     */
    Vector4D getNormal( Vector4D& point );
    
    /**
     * From Object interface:
     * Sets the id of the object's material.
     * All the materials are stored in the Scene class.
     * @param materialId Id of the material
     */
    void setMaterial( int materialId );
    
    /**
     * From Object interface:
     * @return The Id of the object's material
     */
    int getMaterialId();
    
    /**
     * From Object interface:
     * @return The type of the object
     */
    ObjectType getType();
    
    /**
     * From Object interface:
     * Gives access to the min and maximum values of the axis aligned bounding 
     * box of the object
     * @param min Minimum values of the aabb
     * @param max Maximum values of the aabb
     */
    void getBoundingBox( Vector4D& min, Vector4D& max );
    
    /**
     * Gives the radius of the sphere
     * @return Radius of the sphere
     */
    double getRadius();
    
    /**
     * @return center of sphere
     */
    Vector4D getCenter();

private:
    
    /** Center of the sphere */
    Vector4D _center;
    
    /** Radius of the sphere */
    double _radius;
    
    /** Id of the material */
    int _materialId;
};

#endif /* SPHERE_H_ */
